<!-- 写评论的输入框 -->
<template>
	<view>
		<view class="write">
			<view class="cont flex align-center">
				<view class="imgs flex align-center">
					<!-- <view v-if="status != 2" class="icon flex align-center justify-center" @click="show = true">
						<image src="https://sanfuzhide.oss-cn-hangzhou.aliyuncs.com/circle/qiehuan.png" mode=""></image>
					</view> -->
					<view class="img">
						<image :src="identity.status == 0?identity.huaimg:avatar" mode=""></image>
					</view>
				</view>
				<view class="search" v-if="status == 0">
					<u-input placeholder="我来说几句..." height="54" search-icon="" :cursor-spacing="7" :clearable="false" confirm-type="确认"
						v-model="submitQurey.content" :show-action="false" @confirm="submit">
					</u-input>
				</view>
				<view class="search" v-if="status == 1">
					<u-input placeholder="我来说几句..." height="54" search-icon="" :cursor-spacing="7" :clearable="false" confirm-type="确认"
						v-model="articleQurey.content" :show-action="false" @confirm="submit1">
					</u-input>
				</view>
				<view class="search" v-if="status == 2">
					<u-input placeholder="我来说几句..." height="54" search-icon="" :cursor-spacing="7" :clearable="false" confirm-type="确认"
						v-model="treeHoleQurey.content" :show-action="false" @confirm="submit2">
					</u-input>
				</view>
			</view>
		</view>
		<!-- <view v-if="show" class="mask" :style="{'height': `calc(100vh - 75rpx - env(safe-area-inset-bottom))`}"
			@click.stop="canel">
			<view class="identity">
				<view class="title flex justify-center align-center">
					选择身份
				</view>
				<view class="ident">
					<view class="item flex justify-between align-center" @click="choose0">
						<view class="left flex align-center">
							<view class="img flex align-center justify-center">
								<image :src="identity.huaimg" mode=""></image>
							</view>
							<view class="name">
								花名
							</view>
						</view>
						<view v-if="identity.status == 0" class="icon flex align-center justify-center">
							<image src="https://sanfuzhide.oss-cn-hangzhou.aliyuncs.com/circle/xuanzhong.png" mode="">
							</image>
						</view>
					</view>
					<view style="height: 35rpx;width: 100%;">

					</view>
					<view class="item flex justify-between align-center">
						<view class="left flex align-center">
							<view class="img flex align-center justify-center">
								<image :src="avatar" mode=""></image>
							</view>
							<view class="name">
								实名
							</view>
						</view>
						<view v-if="identity.status == 1" class="icon flex align-center justify-center">
							<image src="https://sanfuzhide.oss-cn-hangzhou.aliyuncs.com/circle/xuanzhong.png" mode="">
							</image>
						</view>
					</view>
					<view style="height: 35rpx;width: 100%;">

					</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import {
		identity
	} from '@/data/comments.js'
	export default {
		name: "evaluation",
		props: {
			status: {
				type: Number,
				default: 0
			},
			avatar: {
				type: String
			},

		},
		data() {
			return {
				identity,
				show: false,
				submitQurey: {
					content: '',
					attentionListId: ''
				},
				articleQurey: {
					content: '',
					articleListId: ''
				},
				treeHoleQurey: {
					content: '',
					hollowListId: ''
				},
			};
		},
		onLoad() {
			this.avatar = uni.getStorageSync('avatar')

		},
		methods: {
			//点击遮罩层
			canel() {
				this.show = false
			},
			//点花名
			choose0() {
				this.identity.status = 0
				this.show = false
			},
			//点实名
			choose1() {
				this.identity.status = 1
				this.show = false
			},
			submit() {
				if (uni.getStorageSync('openId')) {
					if(this.submitQurey.content.length > 0){
						this.submitQurey.attentionListId = uni.getStorageSync('pageNum')
						this.$post('/attentionComment/save', this.submitQurey)
						this.$emit('shuaxin')
						uni.setStorageSync('likeId0',this.submitQurey.attentionListId)
						this.submitQurey.content = ''
					}else{
						uni.showToast({
							title: '内容不能为空',
							icon: 'none'
						})
					}
				} else {
					uni.navigateTo({
						url: '../../pages/login/login'
					})
				}

			},
			submit1() {
				if (uni.getStorageSync('openId')) {
					if(this.articleQurey.content.length > 0){
						this.articleQurey.articleListId = uni.getStorageSync('pageNum')
						this.$post('/articleComment/save', this.articleQurey)
						this.$emit('shuaxin')
						uni.setStorageSync('likeId1',this.articleQurey.articleListId)
						this.articleQurey.content = ''
					}else{
						uni.showToast({
							title: '内容不能为空',
							icon: 'none'
						})
					}
				} else {
					uni.navigateTo({
						url: '../../pages/login/login'
					})
				}

			},
			submit2() {
				if (uni.getStorageSync('openId')) {
					if(uni.getStorageSync('flowerName')){
						if(this.treeHoleQurey.content.length > 0){
							this.treeHoleQurey.hollowListId = uni.getStorageSync('pageNum')
							this.$post('/hollowComment/save', this.treeHoleQurey)
							this.$emit('shuaxin')
							uni.setStorageSync('likeId2',this.treeHoleQurey.hollowListId)
							this.treeHoleQurey.content = ''
						}else{
							uni.showToast({
								title: '内容不能为空',
								icon: 'none'
							})
						}
					}else{
						uni.showToast({
							title:'请先设置您的花名',
							icon: 'none'
						})
					}
					
				} else {
					uni.navigateTo({
						url: '../../pages/login/login'
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	.write {
		position: fixed;
		bottom: 0;
		left: 0;
		padding-bottom: env(safe-area-inset-bottom);
		background: #FFFFFF;
		width: 100%;
		border-top: 1rpx solid #f1f1f1;

		.cont {
			padding: 0 30rpx;
			height: 74rpx;

			.imgs {
				height: 74rpx;
				width: 67rpx;
				margin-right: 13rpx;
				position: relative;

				.icon {
					width: 22rpx;
					height: 22rpx;
					position: absolute;
					top: 2rpx;
					right: 0;
				}

				.img {
					width: 54rpx;
					height: 54rpx;
				}
			}

			.search {
				height: 54rpx;
				width: 100%;
			}
		}
	}

	.mask {
		width: 100%;
		background: rgba(0, 0, 0, .4);
		position: fixed;
		left: 0;
		bottom: calc(70rpx + env(safe-area-inset-bottom));

		.identity {
			width: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			padding: 40rpx 30rpx 0;
			background: #FFFFFF;
			border-radius: 24rpx 24rpx 0px 0px;

			.title {
				margin-bottom: 35rpx;
				font-weight: bold;
				color: #333333;
				font-size: 28rpx;
			}

			.ident {
				.item {
					.left {
						.img {
							width: 54rpx;
							height: 54rpx;
							margin-right: 30rpx;
						}

						.name {
							font-weight: 500;
							color: #333333;
							font-size: 28rpx;
						}
					}

					.icon {
						width: 24rpx;
						height: 24rpx;
					}
				}
			}
		}
	}
</style>
